// 导入axios实例中的AxiosResponse泛型接口
import type { AxiosResponse } from "axios";
//导入封装的axios请求方法
import request from "../requestMethod";
import type {loginOrRegReq} from "@/interfaces/login";
import type {MovieDetailReqVO, PageMovieReqVO} from "@/interfaces/movie";
import type {PageMovieSessionReqVO} from "@/interfaces/movie-session";
import type {GetByIdReqVo} from "@/interfaces/base";
import type {DoChargeReqVO, GetUserInfoReqVO, UpdateUserInfoReqVO} from "@/interfaces/user-info";
import type {ApplyCancelOrderReqVO, DoPayReqVO, PageMovieOrderReqVO} from "@/interfaces/order";
// 参数类型导入


//  如果是get请求不需要写method，post请求使用data请求体 默认封装的get
// post示例
//  export const login = (data) => request({ method: "post", url: '/login', data: data });

// get示例
//  export const getUserList = (params) => request({ url: '/users', params });

// put示例
//     export const getEdit = (data) => request({
//      method: "put",
//      data,
//      url: "users/" + data.uid + "/state/" + data.type,
//    })




/**
 * 登录接口
 * @param data
 */
export const useLoginApi = (data:loginOrRegReq):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/uniApp/user/loginOrReg",
        data,
    })
/**
 * 获取电影列表
 * @param data
 */
export const usePageMovieApi = (data: PageMovieReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/uniApp/movie",
        data,
    })
/**
 * 获取电影场次列表
 * @param data
 */
export const usePageMovieSessionByIdApi = (data: PageMovieSessionReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/uniApp/movieSession",
        data,
    })
/**
 * 获取影片详情
 * @param data
 */
export const useMovieDetailApi = (data: MovieDetailReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/uniApp/movie/detail",
        data,
    })
/**
 * 获取场次详情
 * @param data
 */
export const useGetSessionDetailApi = (data: GetByIdReqVo):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/uniApp/session/detail",
        data,
    })

/**
 * 用户信息更改
 * @param data
 */
export const useUpdateUserInfoApi = (data: UpdateUserInfoReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/user/edit",
        data,
    })
export const useDoPayApi = (data: DoPayReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieOrder/doPay",
        data,
    })
export const useGetUserInfoApi = (data: GetUserInfoReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/user/info",
        data,
    })
export const useGetMovieTypeListApi = ():Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieType/selectList"
    })
export const usePageMovieOrderApi = (data: PageMovieOrderReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieOrder",
        data,
    })
export const useApplyCancelOrderApi = (data: ApplyCancelOrderReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/cancelOrder/apply",
        data,
    })

export const useDoChargeApi = (data: DoChargeReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/charge/do",
        data,
    })

// 如何在组件使用
/*
// post请求
import { login } from "@/api/api";
const { data: res } = await login(loginForm);
if (res.meta.status !== 200) return ELMessage.error("登录失败！");
ELMessage.success("登录成功！");
// 保存token
localStorage.setItem("token", res.data.token);
// 跳转到首页
router.push("/");
// 获取用户信息
getUserInfoList();
// get请求
import { getUserList } from "@/api/api";
const { data: res } = await getUserList({ pageNum: 1, pagesize: 2 });
if (res.meta.status !== 200) return ELMessage.error("获取分类列表失败！");
editCateForm = res.data;
editCateDialogVisible.value = true;
// put请求
import { getEdit } from "@/api/api";
const { data: res } = await getEdit({
  uid: row.uid,
  type: row.mg_state,
});
if (res.meta.status !== 200) return ELMessage.error("修改状态失败！");
ELMessage.success("修改状态成功！");
getUserList();
*/